package com.eanh;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RedirServlet extends HttpServlet
{
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        response.setContentType("text/html");
        response.setStatus(HttpServletResponse.SC_OK);
        String s = new String("http://eanhimages.s3.amazonaws.com/");
        String t = request.getPathInfo();
        t = cleanString(t);
        //t = fixImageName(t);

		response.sendRedirect (s+t);
    }

	protected static String cleanString(String s)
	{
		String[] S = s.split("/");
		return S[S.length-1];
	}

	protected static String fixImageName(String s)
	{
		if (s.indexOf("_thumb")==-1)
		{
			s = s.replace(".", "_thumb.");
		}
		return s;
	}
}










